//
//  HWInviteRecordCell.swift
//  HWanGame
//
//  Created by 王昌健 on 2022/9/15.
//  Copyright © 2022 94Wan. All rights reserved.
//

import UIKit

class HWInviteRecordCell: UITableViewCell {
    var nameLabel:UILabel!
    var timeLabel:UILabel!
    var priceLabel:UILabel!
    var rewardLabel:UILabel!
    var lineView:UIView!
    var model:HWInviteSendRecordModel? {
        didSet {
            nameLabel.text = model?.user_name
            timeLabel.text = model?.time
            priceLabel.text = model?.coin
            rewardLabel.text = model?.type
        }
    }
    class func cellWithTableView(tableView:UITableView) -> (HWInviteRecordCell) {
        let reUse:String = "HWInviteRecordCell"
        
        var cell = tableView.dequeueReusableCell(withIdentifier: reUse)
        
        if cell == nil {
            cell = HWInviteRecordCell.init(style: UITableViewCell.CellStyle.default, reuseIdentifier: reUse)
        }
        
        return cell as! HWInviteRecordCell
    }
    
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        initUI()
        initFrame()
    }
    
    func initUI() -> Void {
        selectionStyle = UITableViewCell.SelectionStyle.none
        backgroundColor = UIColor.white
        
        nameLabel = HWLabel.createLabel(title: "", color: "#888888", font: 11*widthScale)
        contentView.addSubview(nameLabel)
        
        timeLabel = HWLabel.createLabel(title: "", color: "#888888", font: 11*widthScale)
        contentView.addSubview(timeLabel)
        
        priceLabel = HWLabel.createLabel(title: "", color: "#888888", font: 11*widthScale)
        contentView.addSubview(priceLabel)
        
        rewardLabel = HWLabel.createLabel(title: "", color: "#888888", font: 11*widthScale)
        contentView.addSubview(rewardLabel)
        
        lineView = UIView()
        lineView.backgroundColor = .colorWithHexString(hexString: "#EEEEEE")
        contentView.addSubview(lineView)
        
    }
    
    func initFrame() -> Void {
        nameLabel.snp.makeConstraints { make in
            make.left.equalTo(18*widthScale)
            make.top.equalTo(8*widthScale).priority(.high)
            make.height.equalTo(15*widthScale)
            make.width.equalTo(94*widthScale)
        }
        
        timeLabel.snp.makeConstraints { make in
            make.left.equalTo(nameLabel.snp.right)
            make.centerY.equalTo(nameLabel)
            make.height.equalTo(15*widthScale)
            make.width.equalTo(113*widthScale)
        }
        
        priceLabel.snp.makeConstraints { make in
            make.left.equalTo(timeLabel.snp.right)
            make.centerY.equalTo(nameLabel)
            make.height.equalTo(15*widthScale)
            make.width.equalTo(99*widthScale)
        }
        
        rewardLabel.snp.makeConstraints { make in
            make.left.equalTo(priceLabel.snp.right)
            make.centerY.equalTo(nameLabel)
            make.height.equalTo(15*widthScale)
            make.width.equalTo(51*widthScale)
        }
        
        lineView.snp.makeConstraints { make in
            make.left.right.bottom.equalToSuperview()
            make.height.equalTo(1)
            make.top.equalTo(nameLabel.snp.bottom).offset(9*widthScale)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
